package Class::Value::Contact::PhoneLikeNumber;

# $Id: PhoneLikeNumber.pm 13653 2007-10-22 09:11:20Z gr $

use strict;
use warnings;


our $VERSION = '0.02';


use base 'Class::Value::Contact';


__PACKAGE__->mk_abstract_accessors(qw(
    NORMALIZE_EXCEPTION_NAME INVALID_VALUE_EXCEPTION_NAME
));


sub normalize_value {
    my ($self, $value) = @_;
    local $_ = $value;
    return unless s/^(00|\+)//;
    s/\D//g;
    $_ = "+$_";
    return if length() < 8 || length() > 21;
    return $_;
}


sub send_notify_value_invalid {
    my ($self, $value) = @_;
    my $class = $self->INVALID_VALUE_EXCEPTION_NAME;
    $self->exception_container->record(
        $class,
        phone  => $value,
    );
}


sub send_notify_value_normalized {
    my ($self, $value, $normalized) = @_;
    my $class = $self->NORMALIZE_EXCEPTION_NAME;
    $self->exception_container->record(
        $class,
        original    => $value,
        replacement => $normalized,
    );
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - contact-related value objects

=head1 SYNOPSIS

    {% p.package %}->new;

=head1 DESCRIPTION

None yet. This is an early release; fully functional, but undocumented. The
next release will have more documentation.

=head1 METHODS

=over 4

{% p.write_methods %}

=back

{% p.write_inheritance %}

{% PROCESS standard_pod %}

=cut

